What is sub query and defines its properties?
What is sub query and its properties?
561
09-Nov-2021
Updated on 09-Nov-2021
Steilla Mitchel
09-Nov-2021SQL subquery and its property:
A subquery is often used inside a main query like Select, Update, Insert or Delete statements. A subquery can be used when expression is allowed. A subquery is also used to create a temporary table on which the main query is executed. Properties of sub query can be defined as follow
• Order By clause is not used with Subquery in SQL
• A sub query should be written in the right side of the comparison operator of the main query.
• A subquery is enclosed within the parenthesis because it is execute first before the main query.
• More than one sub query can be included in a main query.
Types of Subquery
There are generally three types of sub query –
• Single row sub query. It is returns only one row
• Multiple row sub query. It returns multiple rows
• Multiple column sub query. It returns multiple columns to the main query. Main query is executed according the sub query result.
Example-